﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GMap.NET;
using GMap.NET.MapProviders;
using GMap.NET.WindowsPresentation;

namespace ImmovablesManager
{
    /// <summary>
    /// Interaction logic for Map.xaml
    /// </summary>
    public partial class Map : Window
    {

        public Map()
        {
            InitializeComponent();
            MainMap.Manager.Mode = AccessMode.ServerAndCache;
            MainMap.MapProvider = GMapProviders.YandexMap;
            MainMap.ShowTileGridLines = false;
            MainMap.MinZoom = 1;
            MainMap.MaxZoom = 20;
            MainMap.Zoom = 17;

        }

        public bool Find(string address)
        {
            var searchResult = MainMap.SetCurrentPositionByKeywords(address);
            if(searchResult == GeoCoderStatusCode.G_GEO_SUCCESS)
            {
                //Circle circleMarker = new Circle();

                var customMarker = new CustomMarker(address);
                var gMapMarker = new GMapMarker()
                                     {
                                         Shape = customMarker,
                                         Position = MainMap.Position
                                    };

                MainMap.Markers.Add(gMapMarker);
                return true;
            }
            return false;
        }
 
    }
}
